<template>

<table class="table table-bordered" >
    <thead>
        <tr>
            <th>职员id</th>
            <th>职员姓名</th>
            <th>职员手机号</th>
            <th>1男0女</th>
            <th>家庭住址</th>
            <th>部门id</th>
            <th>薪资</th>
            <th>绩效</th>
            <th>逻辑删除</th>
            <th>删除时间</th>
            <th>添加数据时间</th>
            <th>操作</th>

        </tr>
    </thead>

    <tbody v-for="item in tainaji1"> 
        <tr>
            <th>{{ item.zid }}</th>
            <th>{{ item.zname}}<</th>
            <th>{{ item. phone}}<</th>
            <th>{{ item.sex }}<</th>
            <th>{{ item. address}}<</th>
            <th>{{ item.bid }}<</th>
            <th>{{ item. price}}<</th>
            <th>{{ item. jiXiao}}<</th>
            <th>{{ item.isDel }}<</th>
            <th>{{ item.dewltime }}<</th>
            <th>{{ item.addtime }}<</th>
            <th><button @click="IsDel(item.zid)">删除</button>
                <a href="#" @click="Xg(item.zid)">修改</a>
            </th>

        </tr>


    </tbody>


</table>






</template>

<script setup lang="ts">

import { useCounterStore } from '@/stores/use';
import axios from 'axios';
import { onMounted ,ref} from 'vue';

const   nn =  useCounterStore();


    const  Login1 =()=>{

            if(nn.aa=='')
            {
                router.push('/Login')
            }

    }


onMounted(()=>{

    alert(nn.aa)
    Login1();
    Show();
})


const tainaji1 =ref([{

"zid": 0,
  "zname": "string",
  "phone": "string",
  "sex": 0,
  "address": "string",
  "bid": 0,
  "price": 0,
  "jiXiao": 0,
  "isDel": true,
  "dewltime": "2024-12-25T12:52:17.599Z",
  "addtime": "2024-12-25T12:52:17.599Z"


}])


const Show=()=>{

    axios.get('https://localhost:7288/api/ZhiYuan/ShowZhiYuan').then(res=>{

         
        tainaji1.value=res.data.data

    })


}


const IsDel=(id:number)=>{

 

    axios.delete('https://localhost:7288/api/ZhiYuan/IsDel',{params:{
        id:id,
    }}).then(res=>{
        if(res.data>0)
    {
        alert('删除成功')
        Show();
    }
    else
    {
        alert('删除失败')
    }
    })

}

import { useRouter,createRouter} from 'vue-router';


const router=useRouter()
const Xg=(id:number)=>{

    router.push({
        name:'UpdateZhiWei',
        params:{
            id:id,
        }


    })


}

</script>